package com.daidai.activitys

import android.os.Bundle
import android.view.View
import android.widget.ImageView
import androidx.appcompat.app.AppCompatActivity
import com.daidai.IBack
import com.daidai.custom.MyFirstPopWindow
import com.daidai.tools.G
import com.daidai.spinner.R

class TestPopWindowActivity : AppCompatActivity() {

    lateinit var ivIcon:ImageView
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_test_popwindow)
        ivIcon = findViewById(R.id.ivIcon)
        findBtn(R.id.btnShow).setOnClickListener {

//            val dm = resources.displayMetrics
//            val view = LayoutInflater.from(this).inflate(R.layout.popwindow,null,false)
//            val ppWindow = PopupWindow(view,dm.widthPixels,dm.heightPixels,true)
//            ppWindow.isTouchable = true
//            ppWindow.isOutsideTouchable = true
//            ppWindow.showAsDropDown(ivIcon)
//
//            elog("XXXX called!....")
//            view.findViewById<Button>(R.id.btnHide).setOnClickListener {
//                elog("hide btn clicked!")
//                ppWindow.dismiss()
//            }
            G.elog("显示 popWindow")
            val popWindow = MyFirstPopWindow(this)
            popWindow.innerWindow.showAsDropDown(ivIcon)
            popWindow.innerWindow.backCallback = IBack{
                G.elog("返回键被点击......")
            }
        }
    }
    fun findBtn(viewId: Int) = findViewById<View>(viewId)

}